
<?php/* * Created on May 21, 2009 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */require_once ('DBManager.php');class Dao{	protected $mysqli = NULL;	public function __construct()	{		$dbManager = DBManager :: getInstance();		$this->mysqli = $dbManager->getMysqlHandle();	}	/*	 * run the query	 */	public function run($query)	{		$result = mysqli_query($this->mysqli, $query) or die('Query				failed: ' . mysql_error());		return $result;	}	/*	 * prepare the query	 */	public function prepare($query, $types, $params)	{		$stmt = $this->mysqli->prepare($query);		$bind_names[] = $types;		for ($i = 0; $i < count($params); $i++)		{			$bind_name = 'bind' . $i;			$$bind_name = $params[$i];			$bind_names[] = & $$bind_name;		}		call_user_func_array(array (			$stmt,			'bind_param'		), $bind_names);		$stmt->execute();		return $stmt;	}}?>
